-
Notifications
You must be signed in to change notification settings - Fork 244
feat: rewrite with clean api #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1f818da
to
398d9d8
Compare
Major changes: - Remove global monkey patching from ActiveRecord connections - Use model-level with_advisory_lock instead of connection-level - Add multi-database support (PostgreSQL, MySQL, SQLite) - SQLite models don't support advisory locks (returns false) - Add DatabaseCleaner configuration for multi-database tests - Rename SqliteTag to MemoryTag to avoid SQLite reserved prefix - Fix MySQL connection to use 127.0.0.1 instead of localhost - Use CRC32 for advisory lock names to fit MySQL 64-char limit - Add RuboCop and apply auto-corrections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates closure_tree to use a dummy Rails app structure for testing and implements proper multi-database support, removing global monkey patching in favor of the new API patterns from the with_advisory_lock gem. The main changes include creating a standard Rails test environment with database-specific model classes and updating test infrastructure to support concurrent testing across PostgreSQL, MySQL, and SQLite.
Key changes:
- Migrated from standalone test setup to Rails dummy app structure with proper database configuration
- Implemented multi-database support with separate base classes for PostgreSQL, MySQL, and SQLite
- Converted Minitest describe/it syntax to Rails test methods using dynamic method definitions
Reviewed Changes
Copilot reviewed 95 out of 100 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/test_helper.rb | Complete rewrite to use Rails dummy app and configure multi-database testing |
test/support/tag_examples.rb | Converted from describe/it to Rails test methods with dynamic definitions |
test/dummy/ | New Rails dummy application structure with multi-database models and configuration |
test/closure_tree/ | Updated test files to use new dummy app structure and converted syntax |
Comments suppressed due to low confidence (5)
test/support/tag_examples.rb:70
- The test method name has inconsistent spacing. It should be 'test_should_find_tag_by_valid_path' to match the naming pattern of other test methods.
define_method 'test_should find tag by valid path' do
test/support/tag_examples.rb:76
- The test method name has inconsistent spacing. It should be 'test_adds_children_through_add_child' to match the naming pattern of other test methods.
define_method 'test_adds children through add_child' do
test/support/tag_examples.rb:89
- The test method name has inconsistent spacing. It should be 'test_adds_children_through_collection' to match the naming pattern of other test methods.
define_method 'test_adds children through collection' do
test/support/tag_examples.rb:112
- The test method name contains spaces and special characters. It should be 'test_3_tag_collection_create_hierarchy' to follow standard Ruby method naming conventions.
define_method 'test_3 tag collection.create hierarchy' do
test/support/tag_examples.rb:192
- The test method name contains spaces. It should be 'test_3_tag_explicit_create_hierarchy' to follow standard Ruby method naming conventions.
define_method 'test_3 tag explicit_create hierarchy' do
Summary
This PR migrates closure_tree to match the new API patterns from the with_advisory_lock gem, removing global monkey patching and implementing proper multi-database support.
Major Changes
1. Remove Global Monkey Patching
ActiveSupport.on_load
for specific adapters only2. Multi-Database Support
3. Advisory Lock Implementation
model_class.with_advisory_lock
instead ofconnection.with_advisory_lock
4. Test Infrastructure Updates
5. Code Quality
Testing
All tests pass with the new multi-database setup:
Breaking Changes
This removes the global monkey patching behavior. Applications relying on
connection.with_advisory_lock
will need to update to usemodel.with_advisory_lock
instead.